//
//  PingLunCollectionTableView.m
//  Experss
//
//  Created by wmwMAC on 17/8/10.
//  Copyright © 2017年 嗯，大葱. All rights reserved.
//

#import "PingLunCollectionTableView.h"
#import "DingDanTableCollectionViewCell.h"


@interface PingLunCollectionTableView ()<UICollectionViewDelegate,UICollectionViewDataSource>
{
    UIViewController *currentVC;
}

@property (nonatomic , strong) UICollectionView *collectionView;

@property (nonatomic , strong) NSArray *imageArray;

@end
@implementation PingLunCollectionTableView

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.imageArray = [NSArray array];
    self.imageArray = _dataArray;
    
    [self createSubviews];
    
    currentVC = [BasePublicClass getCurrentVC];
}
- (void)createSubviews{
    
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.minimumInteritemSpacing = 10;
    layout.minimumLineSpacing = 20;
    layout.sectionInset = UIEdgeInsetsMake(10, 50, 6, 20);
    CGFloat width = (kScreen_Width - 70 - 60 )/3.0;
    layout.itemSize = CGSizeMake(width, width);
    layout.scrollDirection = UICollectionViewScrollDirectionVertical;
    
    UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, ContentHEIGHT) collectionViewLayout:layout];
    collectionView.backgroundColor = [UIColor whiteColor];
    collectionView.showsVerticalScrollIndicator = NO;
    collectionView.showsHorizontalScrollIndicator = NO;
    collectionView.bounces = NO;
    collectionView.scrollEnabled = NO;
    [collectionView registerClass:[DingDanTableCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    collectionView.delegate = self;
    collectionView.dataSource = self;
    self.collectionView = collectionView;
    [self.contentView addSubview:collectionView];
    collectionView.userInteractionEnabled = NO;
    
    
    
    
    
    
    
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.imageArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    DingDanTableCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    cell.imgV.backgroundColor = [UIColor cyanColor];
    
    //  cell.imgV.image = self.imageArray[indexPath.item];
    
      [cell.imgV sd_setImageWithURL:[NSURL URLWithString:self.imageArray[indexPath.item]]];
    
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
}





- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
